home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 9 / FM Towns Free Software Collection 9.iso / t_os / shell / tsbgex / src / win / expose.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-16  |  2.5 KB  |  111 lines

  1. #include "win.h"
  2.  
  3. void save(work, x, y, x2, y2)
  4. char *work;
  5. int x, y, x2, y2;
  6. {
  7.     struct window *w;
  8.     int sx, sy, sx2, sy2, width;
  9.     extern struct list tail;
  10.     extern void (*blkcpy)(), (*fbread)();
  11.  
  12.     width = x2 - x + 1;
  13.     (*fbread)(work, x, y, width, y2 - y + 1);    
  14.     for (w = tail.prev; w->prev != NULL; w=w->prev){
  15.         if (!w->mapped)
  16.             continue;
  17.         sx = max(x, w->x);
  18.         sy = max(y, w->y);
  19.         sx2 = min(x2, w->x2);
  20.         sy2 = min(y2, w->y2);
  21.         if (sx <= sx2  &&  sy <= sy2  &&  w->save != NULL)
  22.             (*blkcpy)(w->save, sx - w->x, sy - w->y, w->w,
  23.                     work, sx-x, sy-y, width,
  24.                     sx2 - sx + 1, sy2 - sy + 1);
  25.     }
  26. }
  27.  
  28. void expose(work, w, x, y, x2, y2)
  29. char *work;
  30. struct window *w;
  31. int x, y, x2, y2;
  32. {
  33.     int width, height;
  34.     extern void _expose();
  35.     extern struct list head;
  36.     extern void (*blkcpy)(), delete();
  37.     
  38.     if ((width = x2 - x + 1) <= 0)
  39.         return;
  40.     if ((height = y2 - y + 1) <= 0)
  41.         return;
  42.     (*blkcpy)(w->save, x - w->x, y - w->y, w->w,
  43.               work, 0, 0, width, width, height);
  44.     delete(w);    /* temporary */
  45.     _expose(work, width, x, y, x2, y2, head.next);
  46.     w->prev->next = w;
  47.     w->next->prev = w;
  48. }
  49.  
  50. void show(work, w)
  51. char *work;
  52. struct window *w;
  53. {
  54.     extern void _expose();
  55.     extern struct list head;
  56.     extern void (*blkcpy)();
  57.  
  58.     (*blkcpy)(w->save, 0, 0, w->w, 
  59.               work, 0, 0, w->w, w->w, w->h);
  60.     _expose(work, w->w, w->x, w->y, w->x2, w->y2, head.next);
  61. }
  62.  
  63. void _expose(work, width, x, y, x2, y2, w)
  64. char *work;
  65. int width, x, y, x2, y2;
  66. struct window *w;
  67. {
  68.     int sx, sy, sx2, sy2, byte;
  69.     extern int pixelsize, fbxmax;
  70.     extern void (*fbwrite)();
  71.  
  72.     for (; w->next != NULL; w = w->next){
  73.         if (!w->mapped)
  74.             continue;
  75.         sx = max(x, w->x);
  76.         sy = max(y, w->y);
  77.         sx2 = min(x2, w->x2);
  78.         sy2 = min(y2, w->y2);
  79.         if (sx <= sx2  &&  sy <= sy2){
  80.             if (w->save == NULL){ /* don't draw */
  81.                 byte = width * pixelsize;
  82.                 w = w->next;
  83.                 if (y < sy)
  84.                     _expose(work, width, x, y, x2, sy-1, w);
  85.                 if (x < sx)
  86.                     _expose(work+(sy-y)*byte, width, x, sy, sx-1, y2, w);
  87.                 if (sx2 < x2)
  88.                     _expose(work+(sx2+1-x)*pixelsize, 
  89.                             width, sx2+1, y, x2, sy2, w);
  90.                 if (sy2 < y2)
  91.                     _expose(work+(sy2+1-y)*byte, width, x, sy2+1, x2, y2, w);
  92.                 return;
  93.             } else
  94.                 (*w->draw)(w, work, sx - x, sy - y, width,
  95.                             sx - w->x, sy - w->y,
  96.                             sx2 - sx + 1, sy2 - sy + 1);
  97.         }
  98.     }
  99.     if (x < 0){
  100.         byte = x2 - 0 + 1;
  101.         work += -x * pixelsize;
  102.         x = 0;
  103.     } else {
  104.         byte = min(x2, fbxmax) - x + 1;
  105.     }
  106.     if (byte >= 0){
  107.         width -= byte;
  108.         (*fbwrite)(work, x, y, byte, y2 - y + 1, width*pixelsize);
  109.     }
  110. }
  111.